import { SearchData } from './Type';
import TableTemplate from '../TableTemplate/TableTemplate.vue';
export default {
    name: 'AddProjectBudget',
    components: {
        TableTemplate
    },
    data() {
        return {
            ordersPager: {
                pageNum: 0,
                pageSize: 10
            },
            currentRow: null,
            orderTableData: [],
            orderTableConfig: [
                { type: 'radio', width: '50' },
                {
                    label: '工单状态',
                    prop: 'orderStatus',
                    formatter(val) {
                        const statusMap = {
                            1: '待现场勘察',
                            2: '退单中',
                            3: '现场勘察已提交',
                            4: '现场勘察审核通过',
                            5: '现场勘察审核驳回',
                            6: '预算中',
                            7: '预算审批通过',
                            8: '施工中',
                            9: '施工完成',
                            10: '退单驳回',
                            11: '已退单',
                            12: '竣工验收中',
                            13: '已交付'
                        };
                        return statusMap[val];
                    }
                },
                { label: '工单编号', prop: 'orderNo' },
                { label: '网点代码', prop: 'orderDept' },
                { label: '工程名称', prop: 'constructionProjectName' },
                { label: '工程地址', prop: 'constructionProjectAddress' },
                { label: '工程面积', prop: 'constructionProjectArea' }
            ],
            formConfig: [
                {
                    label: '工单编号',
                    prop: 'orderNo'
                },
                {
                    label: '网点代码',
                    prop: 'deptCode'
                },
                {
                    label: '工程名称',
                    prop: 'projectName'
                }
            ],
            formSearch: {
                orderNo: '',
                deptCode: '',
                orderStatus: '4',
                projectName: ''
            },
            dialogVisible: false,
            logs: [],
            searchData: new SearchData(),
            monitoringLevels: [],
            businessTypes: [],
            processStates: []
        };
    },
    mounted() {
        this.initOrders();
    },
    methods: {
        searchHttp() {
            this.initOrders({
                ...this.ordersPager,
                ...this.formSearch
            });
        },
        async initOrders(param = {}) {
            param = { ...param, ...this.ordersPager };
            const orders = await this.$httpExt().post('/api/common/selectOrder', param);

            this.orderTableData = orders.data?.list || [];
        },
        handleClose() {
            this.dialogVisible = false;
        },
        showDialog() {
            this.logs = [];
            this.initOrders();
            this.dialogVisible = true;
        },
        close() {
            this.$parent.currentOrderRow = null;
        }
    }
};
